gtk/gtktextlayout.c (line_display_iter_to_index) Only adjust the preedit
authorOwen Taylor <otaylor@redhat.com>
Thu, 29 Jan 2004 23:33:07 +0000 (23:33 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Thu, 29 Jan 2004 23:33:07 +0000 (23:33 +0000)
Thu Jan 29 18:08:06 2004  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtktextlayout.c (line_display_iter_to_index)
        * gtk/gtktextlayout.c (line_display_index_to_iter): Only
        adjust the preedit position for lines that include the
        preedit string. (#132353, Yao Zhang). How the heck
        did this work as well as it did?!?!

        * modules/input/gtkimcontextxim.c (gtk_im_context_xim_get_ic):
        Reverse change to change of XNFilterEvents event mask from
        #110493 -- it's documented and in the Xlib code an
        unsigned long.

        * modules/input/gtkimcontextxim.c (preedit_start_callback):
        Return -1 rather than void to indicate no length limit.
        (#129548)

gtk/gtktextlayout.c
modules/input/gtkimcontextxim.c

index 3fed7624c47c7943f53b085f628233f8d43c4cb1..157435a8b8036abb6fdb877ff11d7323a612793e 100644 (file)
@@ -2026,8 +2026,11 @@ line_display_iter_to_index (GtkTextLayout      *layout,
 
   index = gtk_text_iter_get_visible_line_index (iter);
   
-  if (index >= display->insert_index)
-    index += layout->preedit_len;
+  if (layout->preedit_len > 0 && display->insert_index >= 0)
+    {
+      if (index >= display->insert_index)
+       index += layout->preedit_len;
+    }
 
   return index;
 }
@@ -2042,12 +2045,15 @@ line_display_index_to_iter (GtkTextLayout      *layout,
   g_return_if_fail (!_gtk_text_line_is_last (display->line,
                                              _gtk_text_buffer_get_btree (layout->buffer)));
   
-  if (index >= display->insert_index + layout->preedit_len)
-    index -= layout->preedit_len;
-  else if (index > display->insert_index)
+  if (layout->preedit_len > 0 && display->insert_index >= 0)
     {
-      index = display->insert_index;
-      trailing = 0;
+      if (index >= display->insert_index + layout->preedit_len)
+       index -= layout->preedit_len;
+      else if (index > display->insert_index)
+       {
+         index = display->insert_index;
+         trailing = 0;
+       }
     }
 
   _gtk_text_btree_get_iter_at_line (_gtk_text_buffer_get_btree (layout->buffer),
index d865fc27136940be2252b4fe5390f4041649bb6c..6b27aa3f0df2f015ed663a738d2a55d09447f955 100644 (file)
@@ -966,7 +966,7 @@ gtk_im_context_xim_get_preedit_string (GtkIMContext   *context,
     *cursor_pos = context_xim->preedit_cursor;
 }
 
-static void
+static int
 preedit_start_callback (XIC      xic,
                        XPointer client_data,
                        XPointer call_data)
@@ -976,6 +976,8 @@ preedit_start_callback (XIC      xic,
   
   if (!context_xim->finalizing)
     g_signal_emit_by_name (context, "preedit_start");
+
+  return -1;                   /* No length limit */
 }                   
 
 static void
@@ -1276,7 +1278,7 @@ gtk_im_context_xim_get_ic (GtkIMContextXIM *context_xim)
           * stroke if both key pressed and released events are filtered.
           * (bugzilla #81759)
           */
-         guint32 mask = 0xaaaaaaaa;
+         gulong mask = 0xaaaaaaaa;
          XGetICValues (xic,
                        XNFilterEvents, &mask,
                        NULL);